home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH7 / SRC / OBJ1SQ.CLS < prev    next >
Encoding:
Text File  |  1995-10-26  |  1.4 KB  |  54 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "ObjSquare"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. Option Explicit
  9.  
  10. Public x As Single
  11. Public y As Single
  12. Public r As Single
  13.  
  14. ' ************************************************
  15. ' Compute the world coordinate bounds for the
  16. ' square.
  17. ' ************************************************
  18. Sub Bound(xmin As Single, ymin As Single, xmax As Single, ymax As Single)
  19.     xmin = x - r
  20.     xmax = x + r
  21.     ymin = y - r
  22.     ymax = y + r
  23. End Sub
  24.  
  25. ' ************************************************
  26. ' Write a square to a file using Write.
  27. ' Begin with "SQUARE" to identify this object.
  28. ' ************************************************
  29. Sub FileWrite(filenum As Integer)
  30.     Write #filenum, "SQUARE", x, y, r
  31. End Sub
  32. Function ObjectType() As String
  33.     ObjectType = "SQUARE"
  34. End Function
  35.  
  36.  
  37.  
  38. ' ************************************************
  39. ' Draw the square on a Form, Printer, or
  40. ' PictureBox.
  41. ' ************************************************
  42. Sub Draw(canvas As Object)
  43.     canvas.Line (x - r, y - r)-(x + r, y + r), , B
  44. End Sub
  45.  
  46. ' ************************************************
  47. ' Read a square from a file using Input.
  48. ' Assume the "SQUARE" label has already been read.
  49. ' ************************************************
  50. Sub FileInput(filenum As Integer)
  51.     Input #filenum, x, y, r
  52. End Sub
  53.  
  54.